home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_FILEROO.PRG
< prev
next >
Wrap
Text File
|
1993-05-04
|
2KB
|
68 lines
FUNCTION _FileRoot
PARAMETER pc_fname
*--------------------------------------------------------------------
* NAME
* _FILEROOT - Returns "root" of a filename.
*
* SYNOPSIS
* _FILEROOT( pc_fname )
*
* DESCRIPTION
* _FILEROOT() isolates the filename, up to the first eight
* characters, from a full path description. That is, the
* file extension, if any, is not returned. Note that the
* following can all be valid filespecs within dBASE:
* FOO
* FOO.BAR
* C:FOO
* C:FOO.BAR
* C:\FOO
* C:\FOO.BAR
* C:\FOO\FOO
* C:\FOO\FOO.BAR
* C:\FOO.BAR\FOO
* C:\FOO.BAR\FOO.BAR
* ..\FOO.BAR
*
* No upper or lower case conversion occurs.
*
* PARAMETER
* pc_fname - A character full DOS filespec.
*
* EXAMPLE
* lc_root = _FileRoot( "C:\TEST\FOO.PRG" )
* ( lc_root will equal "FOO" )
*
* SEE ALSO
* _FILEDRV(), _FILEPATH(), _FILETYPE()
*
*--------------------------------------------------------------------
PRIVATE lc_result, lc_slash
IF LEFT( OS(), 3 ) = "DOS"
lc_slash = "\"
ELSE
lc_slash = "/"
ENDIF
*-- Add "." to end to easily handle file with no extension:
lc_result = LTRIM( RTRIM( pc_fname ) ) + "."
IF lc_slash $ lc_result
lc_result = SUBSTR( lc_result, RAT(lc_slash, lc_result) + 1 )
ELSE
IF ":" $ lc_result
lc_result = SUBSTR( lc_result, AT(":", lc_result) + 1 )
ENDIF
ENDIF
RETURN SUBSTR(lc_result, 1, AT(".", lc_result ) - 1 )
*-- EOF: _FileRoot( pc_fname )